package login

import (
	"Server/internal/model/entity"
	"Server/internal/service"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/util/gconv"
)

type sLogin struct {
	tableName string
}

func New() *sLogin {
	return &sLogin{
		tableName: "sys_users",
	}
}

func init() {
	service.RegisterLogin(New())
}

//LoginService 登录
func (logic *sLogin) LoginService(uname string) *entity.SysUsers {
	if len(uname) <= 0 {
		return nil
	}
	record, err := g.Model(logic.tableName).Where("StaffName", uname).One()
	if err != nil || record == nil {
		return nil
	}
	mod := &entity.SysUsers{}
	gconv.Struct(record, mod)
	return mod
}
